package com.lcb.manager.vo;

import com.alibaba.fastjson.JSON;
import com.lcb.manager.entity.Address;

import java.util.List;

public class AddressVo {

    private Integer id;

    private boolean displayAddress;

    private String text;

    private List<String> pictures;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public boolean isDisplayAddress() {
        return displayAddress;
    }

    public void setDisplayAddress(boolean displayAddress) {
        this.displayAddress = displayAddress;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public List<String> getPictures() {
        return pictures;
    }

    public void setPictures(List<String> pictures) {
        this.pictures = pictures;
    }

    public static AddressVo fromEntity(Address address) {
        if (address == null) return null;
        AddressVo addressVo = new AddressVo();
        addressVo.id = address.getId();
        addressVo.displayAddress = address.isDisplayAddress();
        addressVo.text = address.getText();
        addressVo.pictures = JSON.parseArray(address.getPictures(), String.class);
        return addressVo;
    }
}
